#include <iostream> 

using namespace std; 


//阶乘-递归
int recursion(int n){
	if (n==1){
        return 1;
    }else{
        return n*recursion(n-1);
    }
	
}

//阶乘-递推
int recurrence(int n){
	int result = 1;
	for (int i = 1;i<=n;i++){ //时间复杂度 O(n)
		result = result * i;
	}
	return result;
}


int main(){
	int n;
	cout << "请输入n: ";
	cin >> n;
	cout << n << " 的阶乘是: " <<recursion(n)<<endl;
	cout << n << " 的阶乘是: " <<recurrence(n)<<endl;
	return 0;
}